package com.gxc.config;

import com.github.pagehelper.PageInterceptor;
import java.util.Properties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置Mybatis分页插件PageHelper.
 *
 * @author 宫新程
 * @since 2018/12/28 11:13 AM
 */
@Configuration
public class MybatisConfigBean {

  /** 配置Mybatis分页插件PageHelper. */
  @Bean
  public PageInterceptor pageInterceptor() {
    PageInterceptor pageInterceptor = new PageInterceptor();
    Properties p = new Properties();
    p.setProperty("helperDialect", "mysql");
    p.setProperty("offsetAsPageNum", "true");
    p.setProperty("rowBoundsWithCount", "true");
    p.setProperty("reasonable", "false");
    p.setProperty("supportMethodsArguments", "true");
    pageInterceptor.setProperties(p);
    return pageInterceptor;
  }
}
